<?php
header("content-type:text/html;charset=utf8");
$con=mysqli_connect('localhost','root','root','test');
mysqli_query($con,"set names utf8");
$res = mysqli_query($con,'select * from commodity');
$arr=[];
while($row=mysqli_fetch_assoc($res)){
    $arr[]=$row;
}
if(count($arr)>0){
    echo json_encode([
        'meta'=>[
            'status'=>1,
            'msg'=>'数据请求成功'
        ],
        'data'=>$arr
    ]);
}else{
    echo json_encode([
        'meta'=>[
            'status'=>1,
            'msg'=>'数据请求失败'
        ],
        'data'=>$arr
    ]);
}